package com.meida.student.app.user.controller;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.security.OpenHelper;
import com.meida.common.springmvc.base.BaseController;
import com.meida.module.bus.client.entity.BusOrder;
import com.meida.module.bus.provider.service.BusOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Map;


/**
 * 订单表控制器
 *
 * @author flyme
 * @date 2021-08-03
 */
@RestController
@RequestMapping("/order/")
public class ApiOrderController extends BaseController<BusOrderService, BusOrder> {

    @ApiOperation(value = "订单确认", notes = "订单确认")
    @PostMapping(value = "getWaitConfirmedInfo")
    public ResultBody getWaitConfirmedInfo(Long orderId, Long answerId, Long couponUserId, BigDecimal rewardAmount) {
        return bizService.getWaitConfirmedInfo(orderId, couponUserId, answerId, rewardAmount);
    }


    @ApiOperation(value = "出价列表", notes = "出价列表")
    @GetMapping(value = "offerPriceList")
    public ResultBody offerPriceList(Long orderId) {
        return bizService.offerPriceList(orderId);
    }

    @ApiOperation(value = "还价", notes = "还价")
    @PostMapping(value = "updateBargainPrice")
    public ResultBody updateBargainPrice(@RequestParam(required = false) Map params) {
        return bizService.updateBargainPrice(params);
    }

    @ApiOperation(value = "追问", notes = "追问")
    @PostMapping(value = "askQuestion")
    public ResultBody askQuestion(@RequestParam(required = false) Map params) {
        return bizService.askQuestion(params);
    }


    @ApiOperation(value = "接受答案", notes = "接受答案")
    @PostMapping(value = "acceptAnswer")
    public ResultBody acceptAnswer(Long answerId) {
        return bizService.acceptAnswer(answerId);
    }

    @ApiOperation(value = "拒绝接单", notes = "拒绝接单")
    @PostMapping(value = "refuseAnswer")
    public ResultBody refuseAnswer(Long orderId) {
        return bizService.refuseAnswer(orderId);
    }

    @ApiOperation(value = "关闭直播", notes = "关闭直播")
    @PostMapping(value = "closeLive")
    public ResultBody closeLive(Long orderId, Long answerId) {
        return bizService.closeLive(orderId, answerId);
    }


    @ApiOperation(value = "订单评价", notes = "订单评价")
    @GetMapping(value = "getOrderAppraise")
    public ResultBody getOrderAppraise(@RequestParam(required = false) Map params) {
        return bizService.getOrderAppraise(params);
    }

    @ApiOperation(value = "退款详情", notes = "退款详情")
    @GetMapping(value = "getAfterService")
    public ResultBody getAfterService(@RequestParam(required = false) Map params) {
        return bizService.getAfterService(params);
    }

    @ApiOperation(value = "统计中订单数量", notes = "退款详情")
    @GetMapping(value = "getDoingOrderCount")
    public ResultBody getDoingOrderCount(@RequestParam(required = false) Map params) {
        Long userId = OpenHelper.getUserId();
        Long count = bizService.totalOrder(userId);
        EntityMap map = new EntityMap();
        map.put("orderCount", count);
        return ResultBody.ok(map);
    }

}
